#!/usr/bin/perl

######################################################################
package Swignition::RDFModel::Value;
######################################################################

use XML::LibXML qw(:all);
use strict;

BEGIN
{
	our $VERSION = 0.1;	
}

sub new
{
	my $class = shift;
	my $value = shift;
	my $type  = shift||0;
	
	my $this = {
		value     => $value,
		type      => $type
	};
	
	bless $this;

	if (ref $this->{value} && UNIVERSAL::isa($this->{value}, 'DateTime'))
	{
#		$this->{value} = "$this->{value}";
#		$this->setVocab('http://purl.org/dc/terms/W3CDTF');
		if (length $this->{value}->{datatype})
			{ $this->setDatatype($this->{value}->{datatype}); }
		elsif ($this->{value}->{resolution} eq 'year')
			{ $this->setDatatype('http://www.w3.org/2001/XMLSchema#gYear'); }
		elsif ($this->{value}->{resolution} eq 'month')
			{ $this->setDatatype('http://www.w3.org/2001/XMLSchema#gYearMonth'); }
		elsif ($this->{value}->{resolution} eq 'day')
			{ $this->setDatatype('http://www.w3.org/2001/XMLSchema#date'); }
		else
			{ $this->setDatatype('http://www.w3.org/2001/XMLSchema#dateTime'); }
	}

	if (ref $this->{value} && UNIVERSAL::isa($this->{value}, 'Swignition::MagicDuration'))
	{
#		$this->{value} = "$this->{value}";
		$this->setDatatype('http://www.w3.org/2001/XMLSchema#duration');
	}

	if (ref $this->{value} && UNIVERSAL::isa($this->{value}, 'Swignition::MagicInterval'))
	{
#		$this->{value} = "$this->{value}";
		$this->setDatatype('urn:iso:std:iso:8601#timeInterval');
	}
	
	return $this;
}

sub type
{
	my $this = shift;
	return $this->{type};
}

sub toString
{
	my $this = shift;
	return $this->{value};
}

sub property
{
	my $this = shift;
	return $this->{property};
}

sub setProperty
{
	my $this = shift;
	my $prop = shift;
	
	$this->{property} = $prop;
}

sub vocab
{
	my $this = shift;
	return $this->{vocab};
}

sub setVocab
{
	my $this  = shift;
	my $vocab = shift;
	
	$this->{vocab} = $vocab;
}

sub datatype
{
	my $this = shift;
	return $this->{datatype};
}

sub setDatatype
{
	my $this  = shift;
	my $datatype = shift;
	
	$this->{datatype} = $datatype;
}

sub lang
{
	my $this = shift;
	return $this->{lang};
}

sub setLang
{
	my $this  = shift;
	my $lang = shift;
	
	$this->{lang} = $lang;
}

sub dom
{
	my $this = shift;
	return $this->{dom};
}

sub setDom
{
	my $this = shift;
	my $dom  = shift;
	
	$this->{dom} = $dom;
}




1;
